import { configureStore } from '@reduxjs/toolkit';
import undoable, { excludeAction, StateWithHistory } from 'redux-undo';
import userReducer, { UserStateType } from './UserRuder';
import ComponentsReducer, { ComponentsStateType } from './ComponentsReducer';
import PageInfoReducer, { PageInfoType } from './PageInfoReducer';

export type StateType = {
  user: UserStateType;
  components: StateWithHistory<ComponentsStateType>;
  pageInfo: PageInfoType;
};

export default configureStore({
  reducer: {
    user: userReducer,
    pageInfo: PageInfoReducer,
    components: undoable(ComponentsReducer, {
      limit: 20,
      filter: excludeAction([
        'components/resetComponents',
        'components/changeSelectedId',
        'components/selectPrevComponent',
        'components/selectNextComponent',
      ]),
    }),
  },
});
